<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%nbrb_pledge_info_notice}}".
 *
 * @property int $id
 * @property string $request_seq_no
 * @property string $req_order_number
 * @property string $request_json
 * @property int $created_at
 * @property int $status
 * @property string $pledge_info_number
 *
 * @property NbrbCustomAdmittance $reqOrderNumber
 */
class NbrbPledgeInfoNotice extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%nbrb_pledge_info_notice}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['request_seq_no', 'req_order_number', 'request_json', 'created_at', 'status', 'pledge_info_number'], 'required'],
            [['request_json'], 'string'],
            [['created_at', 'status'], 'integer'],
            [['request_seq_no', 'req_order_number', 'pledge_info_number'], 'string', 'max' => 50],
            [['req_order_number'], 'unique'],
            [['req_order_number'], 'exist', 'skipOnError' => true, 'targetClass' => NbrbCustomAdmittance::className(), 'targetAttribute' => ['req_order_number' => 'order_number']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'request_seq_no' => Yii::t('app', 'Request Seq No'),
            'req_order_number' => Yii::t('app', 'Req Order Number'),
            'request_json' => Yii::t('app', 'Request Json'),
            'created_at' => Yii::t('app', 'Created At'),
            'status' => Yii::t('app', 'Status'),
            'pledge_info_number' => Yii::t('app', 'Pledge Info Number'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getReqOrderNumber()
    {
        return $this->hasOne(NbrbCustomAdmittance::className(), ['order_number' => 'req_order_number']);
    }
}
